//
//  TSCityCommentModel.m
//  TaShuo
//
//  Created by N-X on 2018/1/17.
//  Copyright © 2018年 MRNAN. All rights reserved.
//

#import "TSCityCommentModel.h"

@implementation CommentImageModel

@end

@implementation TSCityCommentModel
+ (NSDictionary *)modelCustomPropertyMapper
{
    return @{
             @"descriptionStr":@"description",
             @"imgModels":@"img"
             };
}

+ (NSDictionary *)modelContainerPropertyGenericClass
{
    return @{@"imgModels":[CommentImageModel class]};
}

- (NSArray *)imageUrlArray
{
    __block NSMutableArray * arr = [NSMutableArray array];
    [self.imgModels enumerateObjectsUsingBlock:^(CommentImageModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        NSString * originUrl = [[obj.url componentsSeparatedByString:@"?"] firstObject];
        NSString * newUrl = [@"https:" stringByAppendingString:[[originUrl componentsSeparatedByString:@":"] lastObject]];
        [arr addObject:newUrl];
    }];
    return arr;
    
    // 模拟“随机图片”
    
//    NSArray *picImageNamesArray = @[ @"pic0.jpg",
//                                     @"pic1.jpg",
//                                     @"pic2.jpg",
//                                     @"pic3.jpg",
//                                     @"pic4.jpg",
//                                     @"pic5.jpg",
//                                     @"pic6.jpg",
//                                     @"pic7.jpg",
//                                     @"pic8.jpg"
//                                     ];
//
//    int random = arc4random_uniform(10);
//
//    NSMutableArray *temp = [NSMutableArray new];
//    for (int i = 0; i < random; i++) {
//        int randomIndex = arc4random_uniform(9);
//        [temp addObject:picImageNamesArray[randomIndex]];
//    }
//    return temp;
}

@end
